<!--
 * @Author: EternityJun 2438965023@qq.com
 * @Date: 2025-05-12 09:58:19
 * @LastEditors: EternityJun 2438965023@qq.com
 * @LastEditTime: 2025-05-19 19:42:28
 * @FilePath: \private-domain-small-program\src\App.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->

<script setup lang="ts">
import { tkCheck, tkSpromoter } from '@/service/index';
import { useAccessStore } from '@/store/access';
import { onLaunch } from '@dcloudio/uni-app';
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
const accessStore = useAccessStore()

onLaunch(() => {
  // const hasLaunched = uni.getStorageSync('hasLaunched')
  // if (hasLaunched) {
  //   uni.setStorageSync('hasLaunched', true)
  //   uni.reLaunch({
  //     url: '/pages-sub/login/index'
  //   })
  // }
  wx.login({
    success(res) {
      if (res.code) {
        /* 推客授权 */
        tkCheck({
          data: {
            appid: accessStore.getAppid(),
            grant_type: "authorization_code",
            js_code: res.code,
            secret: accessStore.getSecret()
          }
        }).then(res => {
          uni.setStorageSync('openid', res.data.openid)
          /* 推客检查 */
          tkSpromoter({
            data: {
              is_simple_register: true,
              sharer_openid: res.data.openid
            }
          }).then(res => {
            uni.setStorageSync('bind_status', res.data.bind_status)
          })
        })

      } else {
        console.log('登录失败！' + res.errMsg)
      }
    }
  })
})
</script>

<style lang="scss">
button::after {
  border: none;
}

swiper,
scroll-view {
  flex: 1;
  height: 100%;
  overflow: hidden;
}

image {
  width: 100%;
  height: 100%;
  vertical-align: middle;
}

.uv-popup__content {
  border-radius: 20rpx !important;
}

.bg_left {
  position: fixed;
  top: 114rpx;
  left: 30rpx;
  z-index: 4;
}

.custom-content {
  margin-top: 104rpx;

  .cont_box {
    width: 472rpx;

    .zhsh_img {
      width: 110rpx;
      height: 110rpx;
    }

    .lie {
      font-family: PingFang SC, PingFang SC;
      font-size: 30rpx;
      font-style: normal;
      font-weight: 400;
      line-height: 60rpx;
      color: #000000;
      text-transform: none;
    }

    .button {
      width: 472rpx;
      height: 96rpx;
      line-height: 90rpx;
      color: #fff;
      background: #FF7D1C;
      border-radius: 198rpx 198rpx 198rpx 198rpx;
    }
  }
}
</style>
